﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jacaranda.Model
{
    public class HasClause : ConditionalExpression
    {
        public Type SearchType { get; set; }

        public ConditionalExpression Condition { get; set; }

        internal override string GenerateSql(Type propertyEntityType)
        {
            return string.Format("EXISTS (SELECT 1 FROM {0} WHERE ({1}))", Metadata.Type(SearchType).TableName, Condition.GenerateSql(SearchType));
        }
    }
}
